import 'package:get/get.dart';
import 'package:xin_he/page/mine/xin_he_mine/x_in_he_my_favor/xin_he_my_favor_item_entity.dart';

import '../../../../service/xin_he_reqest.dart';
import 'x_in_he_my_favor_state.dart';

class XInHeMyFavorLogic extends GetxController {
  final XInHeMyFavorState state = XInHeMyFavorState();


  @override
  void onReady() {
    // TODO: implement onReady
    super.onReady();

    requestMyCollections();
  }

  ///我的收藏
  requestMyCollections () async{

    Map<String,dynamic>map = {

      'userId':'11818469275471873'

    };
    XinHeRequestDataResult result = await XinHeHttpRequestData.requestUniversalPost(url: '/goods/findByUserCollect',params: map,isPost: false);

    if(!result.result ){

    }

    if(result.data['code'] == 0){

     List dataList = result.data['data'] ??[];
     List items = [];
     if(dataList.isNotEmpty) {
       for(var e in dataList){
         XinHeMyFavorItemEntity model = XinHeMyFavorItemEntity.fromJson(e);
         items.add(model);
       }
       state.list.value = items;

     }



    }else {

    }


  }
}
